#创建目录&权限
mkdir -p /home/nfs/mysql/data
sudo chmod 770 -R /home/nfs/mysql
sudo chown root:root -R /home/nfs/mysql

#运行临时容器
docker run -d --rm --name tmp_mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql

#配置文件
docker cp tmp_mysql:/etc/mysql/my.cnf /home/nfs/mysql
docker cp tmp_mysql:/etc/mysql/conf.d /home/nfs/mysql
docker kill tmp_mysql

echo 'skip-name-resolve' >> /home/nfs/mysql/my.cnf
cat /home/nfs/mysql/my.cnf

echo 'lower_case_table_names=1' >> /home/nfs/mysql/conf.d/mysql.cnf
cat /home/nfs/mysql/conf.d/mysql.cnf


#运行正式容器
docker kill mysql
docker rm mysql
docker run -d --name  mysql --network=host \
--restart=always \
-v /home/nfs/mysql:/etc/mysql \
-v /home/nfs/mysql/data:/var/lib/mysql \
-v /home/nfs/mysql/mysql-files:/var/lib/mysql-files \
-e TZ=Asia/Shanghai -e MYSQL_ROOT_PASSWORD=xaMao0IqeqqAQTYJ \
mysql --lower_case_table_names=1

sleep 10s
docker logs mysql

#修改连接数
docker exec -it mysql bash
mysql -uroot -psteden@123
set GLOBAL max_connections=10000;
flush privileges;
exit
exit